<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .box1{width: 300px;height: 300px;background: red}
        .box2{width: 200px;height: 200px;background: green}
        .box3{width: 100px;height: 100px;background: blue}
        span{background: pink}
        .msg{width: 100px;height: 100px;background: yellow}
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2">
            <div class="box3">
                <span>hello</span>
            </div>
        </div>
    </div>
    <div class="msg"></div>
</body>
<script>
    var obox1 = document.querySelector(".box1");
    var obox2 = document.querySelector(".box2");
    var obox3 = document.querySelector(".box3");
    var ospan = document.querySelector("span");
    var omsg = document.querySelector(".msg");

    obox1.addEventListener("click", function(){
        console.log("捕获的red")
    }, true)
    obox1.addEventListener("click", function(){
        console.log("冒泡的red")
    }, false)

    obox2.addEventListener("click", function(){
        console.log("捕获的green")
    }, true)
    obox2.addEventListener("click", function(){
        console.log("冒泡的green")
    }, false)

    obox3.addEventListener("click", function(){
        console.log("捕获的blue")
    }, true)
    obox3.addEventListener("click", function(){
        console.log("冒泡的blue")
    }, false)

    ospan.addEventListener("click", function(){
        console.log("捕获的pink")
    }, true)
    ospan.addEventListener("click", function(){
        console.log("冒泡的pink")
    }, false)

</script>
</html>